{include(head.tpl)}
<body>
<div class="wrapper-content">
    <div class="animated fadeInDown wrap">
        <div class="btn-box">
            <span class="dib padding-5 radius-3 blue roleAdd">创建角色</span>
        </div>
        <table class="table">
            <tr>
                <th>ID</th>
                <th>角色代码</th>
                <th>角色名称</th>
                <th>角色描述</th>
                <th>操作</th>
            </tr>
            {foreach from=listarr item=vo}
                <tr>
                    <td>{$vo.id}</td>
                    <td>{$vo.rolecod}</td>
                    <td>{$vo.rolename}</td>
                    <td>{$vo.description}</td>
                    <td>
                        <span onclick="editRole({$vo.id})" class="dib padding-5 radius-3 orange_2">编辑</span>
                        <span onclick="delRole({$vo.id})" class="dib padding-5 radius-3 orange">删除</span>

                    </td>
                </tr>
            {/foreach}
        </table>
    </div>
</div>

  <script>
  // 添加 或 编辑 角色回调函数
  function editRole_layer(){
    window.location.reload();
    layer.close(layer.index);
  }
  $(function(){
    //添加角色
      $('.roleAdd').click(function(){
          layer.open({
            type: 2,
            title: '创建角色',
            shadeClose: true,
            shade: false,
            maxmin: true, //开启最大化最小化按钮
            area: ['300px', '300px'],
            content:'{ctlurl}/roleAdd',
          });
      })
  })
  //编辑角色
  function editRole(id){
    layer.open({
        type: 2,
        title: '编辑角色',
        shadeClose: true,
        shade: false,
        maxmin: true, //开启最大化最小化按钮
        area: ['300px', '300px'],
        content:'{ctlurl}/roleEdit/role_id/'+id,
    });
  }
  function delRole(id){
      var delRole_layer=layer.confirm('确认要删除吗！', {btn: ['确认','取消'],'title':'删除角色'},function(){
            _ajaxs.post('{ctlurl}/roleDel','id='+id,function _return(hdata){
                if(hdata.status){
                  layer.msg(hdata.msg,function(){
                      window.location.reload();
                  });
                }else{
                  layer.msg(data.msg);
                }
            })
      },function(){
        layer.close(delRole_layer);
      });
  }
  </script>
</body>
</html>
